package com.fita.scheduler.entity;

import javax.persistence.Transient;
import java.util.Date;

/**
 * @description:
 * @author: 11200
 * @date: 2019/9/6
 */
public class UserWallet {

    private Long id;

    /**
     *  余额（分）
     */
    private Integer amount;

    /**
     * 冻结金额（一级代理返点未核销金额）
     */
    private Integer frozenAmount;

    /**
     *  总消费额（分）
     */
    private Integer consumeAmount;

    /**
     *  提现金额（分）
     */
    private Integer withdrawAmount;

    /**
     * 上次修改时间
     */
    private Date lastModifyTime;


    private Long agentCompanyId;

    /**
     * 核销
     * @param amount
     * @return
     */
    public UserWallet consume(Integer amount) {
        this.amount = this.amount + amount;
        this.frozenAmount = this.frozenAmount - amount;
        lastModifyTime = new Date();
        return this;
    }

    @Transient
    public Integer getTotalAmount() {
        return this.amount + this.frozenAmount;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Integer getFrozenAmount() {
        return frozenAmount;
    }

    public void setFrozenAmount(Integer frozenAmount) {
        this.frozenAmount = frozenAmount;
    }

    public Integer getConsumeAmount() {
        return consumeAmount;
    }

    public void setConsumeAmount(Integer consumeAmount) {
        this.consumeAmount = consumeAmount;
    }

    public Integer getWithdrawAmount() {
        return withdrawAmount;
    }

    public void setWithdrawAmount(Integer withdrawAmount) {
        this.withdrawAmount = withdrawAmount;
    }

    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    public Long getAgentCompanyId() {
        return agentCompanyId;
    }

    public void setAgentCompanyId(Long agentCompanyId) {
        this.agentCompanyId = agentCompanyId;
    }
}
